home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / tutorqb.com / TUTOR-01.BAS next >
Encoding:
BASIC Source File  |  1986-12-03  |  14.0 KB  |  270 lines

  1.  
  2. '                        The QuickBASIC Tutorial Series
  3.  
  4. '                                   Part 1
  5. '                            The QuickBASIC Editor
  6.  
  7. '                        Copyright 1986  Ford Software
  8.  
  9. '                             4845 Willowbend Blvd
  10. '                               Houston, TX 77035
  11. '                                 (713) 721-5205
  12. '                           CompuServe ppn: 71355,470
  13.  
  14. 'This Tutorial may not be copied or distributed in any form - printed, on disk
  15. 'or electronically - without the express written permission of Ford Software.
  16. '          Unlicensed distribution is a violation of copyright law
  17. '           and may be subject to civil and criminal prosecution.
  18.  
  19. 'QuickBASIC is the registered trademark of the Microsoft Corporation.
  20. 'Ford Software is not associated in any way with the Microsoft Corporation.
  21.  
  22. '(Make sure NumLock is off and press PgDn)
  23. 'page 2
  24. '                           I N T R O D U C T I O N
  25.  
  26. 'Congratulations! You have purchased one of the best programming environments
  27. 'this author has had the pleasure to have used. Oh sure, it has its quirks and
  28. 'design flaws - even bugs. But none of its shortcomings can seriously detract
  29. 'from its many advantages to the BASIC programmer. Please keep that in mind
  30. 'if we seem to be overly critical (even sarcastic) at times.
  31.  
  32. 'QB2's documentation may seem imposing. That's because it is intended more as
  33. 'a reference book than as a tutorial for learning programming. Our tutorial
  34. 'will both guide you through the manual in a logical order and provide an
  35. 'interactive tutorial for immediate reinforcement of what you have read.
  36.  
  37. 'If you should happen to accidentally erase some lines in one of the tutorial
  38. 'files, just reload the file. To do this, press Alt-F, L, Enter, and enter
  39. 'the name of the tutorial file shown at the top of this screen. You will be
  40. 'asked if you want to save the changes you made to this file. Of course you
  41. 'do not, but convincing QB2 is tough. Use the Tab key to highlight the NO
  42. 'box and press the space bar - DO NOT PRESS THE ENTER KEY.
  43.  
  44. '(Press PgDn)
  45. 'page 3
  46. '                                 Contents
  47. '                 page
  48. '                  4     The Editor's Screen
  49. '                  5     The Keyboard
  50. '                  6     ..Restoring a Changed Line
  51. '                  6     ..Cut and Paste
  52. '                  7     ..Copying
  53. '                  7     ..Deleting Whole Lines
  54. '                  8     The Menu
  55. '                  8     ..Edit
  56. '                  8     ..File
  57. '                  9     ..View
  58. '                  9     ..Search
  59. '                 10     ....Change
  60. '                 11     ..Run (Compiling and Running)
  61. '                 12     Review
  62. '
  63. ' There is no index. To search for a topic, press Ctrl-F and enter the word.
  64. '
  65. '
  66. '(Press PgDn)
  67. 'page 4
  68. '                            The Editor's Screen
  69.  
  70. 'If you have an EGA card and had it in the 43-line mode when you started QB2,
  71. 'you should be seeing 43 lines now. That's fine most of the time (though when
  72. 'you run a program, it will only use the top 25 lines of the screen), but this
  73. 'tutorial has been formatted for the 25-line mode, so return to DOS and change
  74. 'to that mode.
  75.  
  76. 'Now, notice the right side of the screen frame. If you have a color monitor,
  77. 'the frame should be green with a black mark somewhere on it. The black mark
  78. 'indicates graphically where you are in the program code. Press Ctrl-PgUp to
  79. 'move to the top of the file, and you will see the mark at the top of the
  80. 'right frame. At the end of the file, the mark will be at the bottom. Right
  81. 'now it should be about 25% of the way down the side, indicating we are about
  82. '25% of the way through the file.
  83.  
  84. 'The mark at the bottom of the screen shows you your position relative to the
  85. 'maximum line length of 255 characters. However, you should try to limit lines
  86. 'to 80 characters or less so that you don't accidentally miss seeing anything.
  87.  
  88. '(Press PgDn)
  89. 'page 5
  90. '                                The Keyboard
  91.  
  92. 'The Editor's use of the keyboard really takes some getting used to. If you
  93. 'normally leave your NumLock key off, you won't have as much trouble as those
  94. 'who normally leave NumLock on and use the shift key when they want to move
  95. 'the cursor. You will need to leave it off for easy use of the cut and paste
  96. 'features of QB2.
  97.  
  98. 'The status of the NumLock, CapsLock and ScrollLock keys are displayed on the
  99. 'right side of the bar at the top of the screen. (ScrollLock does nothing.)
  100.  
  101. 'The next quirk of the editor is that it does not have an overstrike mode. In
  102. 'other words, you are in the "insert" mode all the time. This seems like a
  103. 'needless limitation and hopefully one that MS will fix in future versions.
  104.  
  105. 'Using the cursor keys, move the cursor to right here --> .
  106. 'Press the Home key and move to the start of the line. Also try the End key
  107. 'and the Ctrl-Left and Ctrl-Right keys to move a word at a time. Ctrl-home
  108. 'moves the cursor to the top of the screen; Ctrl-End, to the bottom.
  109. 'Ctrl-PgUp moves to the start of the file and Ctrl-PgDn to the end.
  110. 'Ctrl-Up and Ctrl-Down scroll the screen a line at a time.     (press PgDn)
  111. 'page 6                     (Keyboard, continued)
  112.  
  113. 'RESTORING A CHANGED LINE:
  114. 'With the cursor right here -->. hold Ctrl and press D to delete to the end of
  115. 'the line. Without moving the cursor, press the Ins key to restore the deleted
  116. 'text. Since QB2 doesn't have an overtype mode you will be using Ctrl-D a lot.
  117. 'Holding the Shift key down and pressing Esc would also restore the deleted
  118. 'text, but this key combination has an even more important feature.
  119.  
  120. 'Put the cursor on this line. Type in some new characters and delete others.
  121. 'Then press Shift-Esc and the original line will be restored. You must press
  122. 'Shift-Esc before you move the cursor from the line you want to restore.
  123.  
  124. 'CUT-AND-PASTE:
  125. 'One of the handiest features of the QB2 editor is the cut-and-paste feature.
  126. 'With NumLock off and the cursor on this line, hold down the Shift key and
  127. 'press the Up cursor. The two lines above will be highlighted. Press the Del
  128. 'key and the lines will disappear. Press the Ins key and they will return.
  129. 'You can highlight large blocks at a time using Shift and PgUp or PgDn. You
  130. 'can highlight a word by pressing Shift-Ctrl-Left/Right, or to the end of a
  131. 'line with Shift-End. After highlighting text, you can un-highlight it by
  132. 'pressing any cursor key but the Del key, or by pressing Esc.        (PgDn)
  133. 'page 7                     (Keyboard, continued)
  134.  
  135. 'COPYING:
  136. 'In addition to moving text with the Del and Ins keys, you can copy it without
  137. 'deleting the original text. With the cursor here -->. press Shift-UpCursor.
  138. 'Now press F2 instead of Del. The text will remain highlighted until you press
  139. 'another key, then it will return to normal, but it is ready to be copied. (It
  140. 'would be less confusing if it returned to normal as soon as F2 is pressed,
  141. 'but don't let that distract you.) Put the cursor at the start of the next
  142. 'line and press the Ins key.
  143.  
  144. 'DELETING WHOLE LINES:
  145. 'If you copied the lines per the instructions in the previous paragraph, you
  146. 'now have a couple of lines above that we don't want. To get rid of them,
  147. 'place the cursor on the line to be deleted and press Ctrl-Y.  This non-
  148. 'mnemonic key combination is evidently a curious bow to WordStar - "curious"
  149. 'because nothing else about the editor resembles WordStar. Oh, well...
  150.  
  151. 'You can also delete a line by just holding down the Del key until all the
  152. 'characters on the line are gone, at which point the line itself will go away.
  153. 'Again, you can restore a deleted line by pressing the Ins key. Only the last
  154. 'line deleted or the last block "cut" can be restored.               (PgDn)
  155. 'page 8
  156. '                                  The Menu
  157. 'EDIT:
  158. 'All the cut, paste and copy functions we have been examining can be accessed
  159. 'by seleting "Edit" from the menu at the top of the screen. To do this, hold
  160. 'the Alt key and press E. A menu of options will pop down. All of the commands
  161. 'in the Edit menu can be invoked by pressing "shortcut" keys which we have
  162. 'been using up until now, such as the Del key to cut, F2 to copy, etc.
  163.  
  164. 'FILE:
  165. 'In contrast to the Edit menu, none of the File menu options can be invoked by
  166. 'pressing shortcut keys. To get to the File menu, you must press Alt-F. You
  167. 'can then select an option by moving the cursor with the cursor keys and
  168. 'pressing Enter or by entering the first letter of the desired command and
  169. 'pressing Enter. If two commands in the same menu start with the same letter,
  170. 'press the letter twice. To get to the File menu, you must press Alt-F.
  171.  
  172. 'Unlike the BASIC interpreter, QB2 will prompt you to save your file if you
  173. 'tell it to Load a new file, start a New file or Quit without saving your file
  174. 'It's the cumulative effect of QB2's many time-saving and work-saving features
  175. 'such as this one that makes QB2 so terrific.
  176. '   (PgDn)
  177. 'page 9                      (The Menu, continued)
  178.  
  179. 'VIEW:
  180. 'The Options function lets you do away with the menu bar and other such things
  181. 'on the screen. After a while, you should be able to live without most of the
  182. 'frills on the screen and enjoy being able to see three more lines of code per
  183. 'screen. The Options function also lets you change screen colors.
  184.  
  185. 'The Errors option erases the Error message block that takes up a lot of the
  186. 'screen when your program hits a snag or if you even just do a Ctrl-Break. It
  187. 'is a little annoying to have to do an Alt-V, E, Enter to clear off the error
  188. 'message every time you Ctrl-Break out of a program, but it's nothing major.
  189.  
  190. 'SEARCH:
  191. 'The Find function is very useful in quickly moving to subroutines, etc. The
  192. 'first option, "Find...", doesn't seem to do anything that the next function,
  193. '"Find selected text", doesn't do and the latter has two advantages. One is
  194. 'that if you have highlighted (selected) text on one line, it will be the text
  195. 'to be searched for. The other is that Ctrl-F is a hot key for Find Selected.
  196. 'and the regular Find has no hot key.  Ctrl-F can also be used in place of
  197. 'Find Next (F3) if doing consecutive Find's.
  198. '   (PgDn)
  199. 'page 10                 (The Menu, Search continued)
  200.  
  201. 'Put the cursor here -> . and press Ctrl-F and type in 'and' as the word to
  202. 'search for. The word here- should be highlighted. Press Ctrl-F again and the
  203. 'next "and" will be highlighted. Remember that if text is highlighted and you
  204. 'start typing over it, the entire highlighted text will disappear at once, so
  205. 'be careful. To un-highlight the text, press ESC or a cursor-movement key.
  206.  
  207. 'CHANGE:
  208. 'This is another major feature that interpretive BASIC does not have: a search
  209. 'and replace function. Change the name of a variable throughout your program
  210. 'with just a few keystrokes. Place the cursor here ->. and press Alt-S, C, and
  211. 'press Enter. For the word to be replace, type "and" (without the quotes) and
  212. 'press the TAB key (not Enter!) to get down to the next line and enter "&" to
  213. 'replace "and", then press Enter. The first "and" will be highlighted. Press
  214. 'the space bar. The change will be made and the next "and" will be highlighted.
  215. 'You can either TAB over to the "cancel" command and press space bar, or press
  216. 'ESC to abort the process. Press Alt-S, C and Enter to view the replace screen
  217. 'again so that you can see some of the other options. One option is to make
  218. 'all the replacements without verifying with you. Pretty dangerous. Another
  219. 'is to make the replace "case" or "whole-word" sensitive. Pretty handy.
  220. '  (PgDn)
  221. 'page 11                     (The Menu, continued)
  222.  
  223. 'RUN:
  224. 'We have seen that there are often several ways to do the same thing in QB2,
  225. 'just as there are in the BASIC language. The same is true when you want to
  226. 'Compile your code and Run it. You can press Alt-R, then C, Enter to compile
  227. 'your code and then press Ctrl-R to run it. Or you can just press Ctrl-R to
  228. 'start with and QB2 will automatically compile the code and run it when it is
  229. 'through. If you want to change some of the compile-time options, press Alt-R
  230. 'and C. Now you must press C again to get to the next option that starts with
  231. 'that letter, then press Enter. Go ahead and do that now. If you don't make it
  232. 'to the compile-time option screen, press ESC and try again: Alt-R, C, C, Ent.
  233.  
  234. 'Use TAB  |    If you press Enter when the Compile screen comes   | Use cursor
  235. '+ space  |    up, this program will compile. Go ahead and try    | to change
  236. 'bar to   |    it. Then press Ctrl-R to run it.                   | options on
  237. 'select   |                                                       | this side
  238. 'options  |    If you want to run the program again and haven't   | and press
  239. 'on this  |    made any changes to the code, you can do so with-  | TAB when
  240. 'side.    |    out re-compiling. Just press Ctrl-R again.         | done.
  241.  
  242. cls:locate 12,39:print "HI!":end                                  '(PgDn)
  243. 'page 12                            Review
  244.  
  245. 'Cursor movement:
  246. 'Try out all the cursor movement keys one more time: the Up and Down arrows;
  247. 'Ctrl-Up and -Down to scroll the screen a line at a time; Ctrl-left and -right
  248. 'to move a word at a time; Home to move to the start of a line and End to the
  249. 'end of a line; Ctrl-Home to move to the top-left of the screen and Ctrl-End
  250. 'move to the bottom left of the screen. In my opinion, this is all more effi-
  251. 'cient than leaving the keyboard to use a mouse, so we have ignored the mouse
  252. 'in this tutorial. However, I have heard other people say they think it is
  253. 'wonderful and makes QB2 easier to use. If you are a mouse user, you should
  254. 'have no trouble figuring out how to use it with QB2.
  255.  
  256. 'Shortcut keys:
  257. 'Ctrl-R to compile and run the program.  Ctrl-F to find text.
  258. 'F2 to store highlighted text for copying.  Del to delete highlighted text.
  259. 'Ins to copy F2'ed text or recall Deleted text.  Shift-ESC to abort changes.
  260. 'F6 to see next error message.  Alt-V,E to get rid of the error message box.
  261.  
  262. 'If you are ready to move on to the next session, press Alt-F, L, Enter, and
  263. 'enter TUTOR-02.
  264. '                             the end of lesson 1
  265.  
  266.  
  267.  
  268.  
  269. 'end of file - press PgUp
  270.